#include <stdio.h>


// 1.exception
// 2.success
// 3.failure
typedef struct{
    char ch[MAXSIZE];
    int length;
}SString;

int index(SString s, SString t) {
    if (t.length == 0 || s.length == 0) return 0;
    else if (t.length == s.length && t.length == 0) return 1;
    else {
        int i=1, j=1;
        while (i <= s.length && j <= t.length) {
            if (s.ch[i] == t.ch[j]) { // match
                   ++i;
                   ++j;
            } else { // not match
                   i = i-j+2; // lenght of movement is 'j-2'
                   j = 1; // j -> 1
            }
        }
        // success (if success, j will overflow)
        if (j > t.length) return i - t.length; // index of match (first position of string)
        else return 0;
    }

}

int main() {
}

